package cn.tannn.ops.message.entity;

import cn.tannn.ops.common.pojo.JpaCommonBean;
import cn.tannn.ops.message.constant.WebHookApp;
import cn.tannn.ops.message.constant.WebHookSecretType;
import cn.tannn.ops.message.entity.converter.WebHookAppConverter;
import cn.tannn.ops.message.entity.converter.WebHookSecretTypeConverter;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * webhook
 *
 * @author <a href="https://t.tannn.cn/">tan</a>
 * @version V1.0
 * @date 2024/8/23 上午10:37
 */
@Entity
@Table(name = "msg_webhook")
@Comment("消息-webhook")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@DynamicUpdate
@DynamicInsert
public class WebHook  extends JpaCommonBean<WebHook> {

    /**
     * webhook name
     */
    @Column(columnDefinition = " varchar(200) ")
    @Comment("webhook name")
    String name;

    /**
     * webhook地址
     */
    @Column(columnDefinition = " varchar(200) ")
    @Comment("webhook地址")
    String url;

    /**
     * 密码密钥
     */
    @Column(columnDefinition = " varchar(200) ")
    @Comment("密码密钥")
    String secret;

    /**
     * 签名类型：
     * todo: 目前没有测试也没有编写任何跟PASSWORD相关的代码
     * @see WebHookSecretType
     */
    @Column(columnDefinition = " varchar(50) ")
    @Comment("签名类型")
    @Convert(converter = WebHookSecretTypeConverter.class)
    WebHookSecretType secretType;

    /**
     * webhook地址所属app[钉钉，飞书，企业微信]
     * @see WebHookApp
     */
    @Column(columnDefinition = " varchar(50) ")
    @Comment("webhook地址所属app")
    @Convert(converter = WebHookAppConverter.class)
    WebHookApp app;

}
